home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 32 / Amiga Format AFCD32 (Nov 1998, Issue 117).iso / -seriously_amiga- / programming / e / newgui / src / plugins / pl_calendar.e < prev    next >
Text File  |  1998-08-10  |  2KB  |  74 lines

  1. OPT     OSVERSION=37
  2. OPT     MODULE
  3.  
  4. MODULE  'newgui/newgui'
  5. MODULE  'tools/textlen'
  6. MODULE  'intuition/intuition'
  7. MODULE  'intuition/gadgetclass'
  8. MODULE  'gadgets/calendar'
  9. MODULE  'graphics/text'
  10. MODULE  'utility/date'
  11.  
  12. EXPORT  CONST   CALENDAR = PLUGIN
  13.  
  14. EXPORT OBJECT calendar OF plugin
  15.   date:PTR TO clockdata
  16. PRIVATE
  17.   calendar:PTR TO gadget
  18.   calendarbase
  19.   resize
  20. ENDOBJECT
  21.  
  22. PROC calendar(date,resizex=FALSE,resizey=FALSE,disabled=FALSE) OF calendar
  23.   self.calendarbase:=OpenLibrary('gadgets/calendar.gadget',37)
  24.   IF self.calendarbase=NIL THEN Raise("cal")
  25.   self.date:=date
  26.   self.resize:=(IF resizex THEN RESIZEX ELSE 0) OR
  27.                (IF resizey THEN RESIZEY ELSE 0)
  28.   self.dis:=disabled
  29. ENDPROC
  30.  
  31. PROC end() OF calendar
  32.   IF self.calendarbase THEN CloseLibrary(self.calendarbase)
  33. ENDPROC
  34.  
  35. PROC min_size(ta,fh) OF calendar IS textlen('Wed',ta)+2*7,fh*7+13
  36.  
  37. PROC will_resize() OF calendar IS self.resize
  38.  
  39. PROC render(ta,x,y,xs,ys,w) OF calendar
  40.   self.calendar:=NewObjectA(NIL,'calendar.gadget',
  41.                            [GA_TOP,y, GA_LEFT,x, GA_WIDTH,xs, GA_HEIGHT,ys,
  42.                             GA_TEXTATTR,ta, GA_RELVERIFY,TRUE,
  43.                             GA_DISABLED,self.dis,
  44.                             CALENDAR_CLOCKDATA,self.date, NIL])
  45.   IF self.calendar=NIL THEN Raise("cal")
  46.   AddGList(w,self.calendar,-1,1,NIL)
  47.   RefreshGList(self.calendar,w,NIL,1)
  48. ENDPROC
  49.  
  50. PROC clear_render(win:PTR TO window) OF calendar
  51.   IF self.calendar
  52.     RemoveGList(win,self.calendar,1)
  53.     DisposeObject(self.calendar)
  54.   ENDIF
  55. ENDPROC
  56.  
  57. PROC message_test(imsg:PTR TO intuimessage,win:PTR TO window) OF calendar
  58.   IF imsg.class=IDCMP_GADGETUP THEN RETURN imsg.iaddress=self.calendar
  59. ENDPROC FALSE
  60.  
  61. PROC message_action(class,qual,code,win:PTR TO window) OF calendar
  62.   self.date.mday:=code
  63. ENDPROC TRUE
  64.  
  65. PROC setdate(date=NIL) OF calendar
  66.   IF date THEN self.date:=date
  67.   SetGadgetAttrsA(self.calendar,self.gh.wnd,NIL,[CALENDAR_CLOCKDATA,self.date,NIL])
  68. ENDPROC
  69.  
  70. PROC disable(disabled=TRUE) OF calendar
  71.   SetGadgetAttrsA(self.calendar,self.gh.wnd,NIL,[GA_DISABLED,disabled,NIL])
  72.   self.dis:=disabled
  73. ENDPROC
  74.